package com.akuhome.resource.util;

import com.akuhome.resource.entity.Result;
import com.akuhome.resource.enums.ResultEnum;
import com.akuhome.resource.exception.ResourceException;

public class ResultUtil {

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>(ResultEnum.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result<Object> error(ResourceException exception){
        Result<Object> result = new Result<>();
        result.setCode(exception.getCode());
        result.setMsg(exception.getMessage());
        return result;
    }
}
